﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AddressSendModle>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:Resources.Addressbook_Title %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="maincontent">
    <div id="tab">
			<ul id="tabs">
				<li rel="my" class="current"><%:Html.ActionLink(Resources.All_Contact, "index", "address", null, null)%></li>		               
				<li rel="company"><%:Html.ActionLink(Resources.All_Contact_Group, "group", "address", null, null)%></li>            
			</ul>
			<div class="clear">
			</div>
		</div>
        <div id="tabcontent">
        <div class="tab" id="my">
        <h2>
            <%:Resources.Addressbook_Title %><div class="searchbox">
                <% using (Html.BeginForm("Index", "address", FormMethod.Get))
                   {  %>
                <input name="key" type="text" class="searchbox" value="<%:Model.key %>" /><input
                    type="submit" value="GO" name="" class="searchbutton"></div>
            <%} %>
        </h2>
        <div id="datagrid">
            <% using (Ajax.BeginForm("deleteAddressByItem", "address", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "address", Confirm = Resources.All_DoubleCheck}, FormMethod.Post))
               { %>
            <%Html.RenderPartial("Address_Book"); %>
            <%} %>
        </div>
        <table>
            <tbody>
                <tr>
                    <td>
                    <% using(Html.BeginForm("Import", "Address", FormMethod.Post, new { id = "importform", enctype = "multipart/form-data" })){ %>
    <%: Html.ValidationSummary() %>
    
        <%--<input type="button" value="<%:Resources.All_Import%>" onclick="document.getElementById('fileUpload').click()" class="button"/>--%>
        <input type="file" id="fileUpload" name="fileUpload" value="<%:Resources.All_Browse %>"/>
        <input type="hidden" id="filename" name="filename" />
        <input type="button" id="btnsubmit" value="<%:Resources.All_Import%>" onclick="getFilename();" class="button"/>
        <input type="button" name="add" value="<%:Resources.All_Export%>" onclick="location.href='export'" class="button" />

    <% } %>
                    </td>
                </tr>
            </tbody>
        </table>
          
        </div>
        </div>
    </div>
    <div id="cetd" style="">
        <% using (Html.BeginForm("AddAddress", "Address", FormMethod.Post, new { id = "test" }))
           { %>
        <div class="label">
            <%:Resources.Addressbook_Title %></div>
            <table>
              <tr>
                <td><label>
           <%:Resources.Addressbook_Name %></label></td>
                <td><input name="name" id="newname" type="text" /></td>
              </tr>
               <tr>
                <td><label>
           <%:Resources.Addressbook_Number %></label></td>
                <td><input name="number" id="newnum" type="text" /></td>
              </tr>
            </table>
               <input name="id" type="hidden" />
        <br />
        <input onclick="return checkinput();" type="submit" name="ok" value="<%:Resources.All_Submit %>" class="button" />
        <input type="button" name="cancle" value="<%:Resources.All_Cancel %>" class="button" onclick="cancles()" />
        <%} %>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <link rel="stylesheet" type="text/css" href="<%:Url.Content("~/Content/css/themes/default/easyui.css")%>" />
    <link rel="stylesheet" type="text/css" href="<%:Url.Content("~/Content/css/themes/icon.css")%>" />
    <link href="<%:Url.Content("~/Content/css/icons.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%:Url.Content("~/Content/css/address.css")%>" rel="stylesheet" type="text/css" />
    <script src="<%:Url.Content("~/Content/js/jquery.easyui.js")%>"></script>
    <script src="<%:Url.Content("~/Content/js/jquery.mask.js")%>"></script>
    <script src="<%:Url.Content("~/Content/js/jquery.alcatel.datagrid.js")%>"></script>
    <script type="text/javascript">
        function opens() { document.getElementById("yyxz").style.display = "inline"; }
        function closes() { document.getElementById("yyxz").style.display = "none"; }
    </script>
    <script type="text/javascript">
        function cancles() { $('#cetd').dialog('close'); }
    </script>
    <script type="text/javascript">
        function adds() {
            $(".maincontent").mask()
            $("#cetd").show()
            var id = 0;
            //信息
            $('#cetd').dialog({
                title: "<%:Resources.SMSTemplate_Create_Edit%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 465
            , height: 260
            , onClose: function () {
                $(".maincontent").unmask()
            }
            }).find("input[name='number']").val("");
            $('#cetd').dialog({
                title: "<%:Resources.SMSTemplate_Create_Edit%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 465
            , height: 260
            , onClose: function () {
                $(".maincontent").unmask()
            }
            }).find("input[name='name']").val("");
            //隐藏的ID
            $('#cetd').dialog({
                title: "<%:Resources.SMSTemplate_Create_Edit%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 465
            , height: 260
            , onClose: function () {
                $(".maincontent").unmask()
            }
            }).find("input[name='id']").val(id)
        }

        function edit(value) {
            
            $(".maincontent").mask()
            var $this = $("img.edit#" + value)
            var number = $this.parent().prev().prev().html().replace(/(^\s*)|(\s*$)/g, "");
            var name = $this.parent().prev().prev().prev().html().replace(/(^\s*)|(\s*$)/g, "")
            var id = value;
            $("#cetd").show()
            //信息
            $('#cetd').dialog({
                title: "<%:Resources.SMSTemplate_Create_Edit%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 465
            , height: 260
            , onClose: function () {
                $(".maincontent").unmask()
            }
            }).find("input[name='number']").val(number);
            $('#cetd').dialog({
                title: "<%:Resources.SMSTemplate_Create_Edit%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 465
            , height: 260
            , onClose: function () {
                $(".maincontent").unmask()
            }
            }).find("input[name='name']").val(name)
            //隐藏的ID
            $('#cetd').dialog({
                title: "<%:Resources.SMSTemplate_Create_Edit%>"
            , iconCls: "icon-template"
                //, border: true
            , width: 465
            , height: 260
            , onClose: function () {
                $(".maincontent").unmask()
            }
            }).find("input[name='id']").val(id)
        }

        function getFilename() {
            var fn = document.getElementById('fileUpload').value;
            if (fn == "")
                return alert("<%:Resources.All_Import_NoFile %>");
            document.getElementById('filename').value = fn;
            var form = document.getElementById('importform');
            form.submit();
        }

        function checkinput() {
            if ($("#newname").val().trim() == "" || $("#newnum").val().trim() == "") {
                alert("<%: Resources.All_Contact_Input %>")
                return false;
            }
            if ($("#newname").val().length > 30) {
                alert("<%: Resources.All_Contact_Input_Name_TooLong %>")
                return false;
            }
            if ($("#newnum").val().length > 20) {
                alert("<%: Resources.All_Contact_Input_Num_TooLong %>")
                return false;
            }
        }

        $(document).ready(function () {
            var $this = $("#address_CSS")
            $this.addClass("current")
        })

//        function String.prototype.Trim() { return this.replace(/(^\s*)|(\s*$)/g, ""); } //去掉前后空格
    </script>
    <%--  <script type="text/javascript">
        function ins() {
            if (confirm("是否确定提交！")) {
//                alert($("img.edit,input[name=add]").parent().prev().html());
//                alert($("img.edit,input[name=add]").parent().prev().prev().html());
                var form1 = document.getElementById('test');
                form1.submit();
            }
        }
    </script>--%>
</asp:Content>
